home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
shape.lha
/
shape
/
slist.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
947b
|
77 lines
include "slist.h"
include <stream.h>
include <stdlib.h>
nt slist::insert(ent a)
if (last)
{
last->next = new slink(a, last->next);
}
else
{
last = new slink(a, 0);
last->next = last;
}
return 0;
nt slist::append(ent a)
if (last)
{
last = last->next = new slink(a, last->next);
}
else
{
last = new slink(a, 0);
last->next = last;
}
return 0;
nt slist::get()
if (last == 0)
slist_handler("get from empty slist");
slink *f = last->next;
ent r = f->e;
if (f == last)
{
last = 0;
}
else
{
last->next = f->next;
}
delete f;
return r;
oid slist::clear()
slink *l = last;
if (l == 0) return;
do {
slink *ll = last;
l = l->next;
delete ll;
} while (l != last);
last = 0;
tatic void default_error(char *s)
cerr << s << "\n";
exit(1);
FC slist_handler = default_error;
FC set_slist_handler(PFC handler)
PFC rr = slist_handler;
slist_handler = handler;
return rr;